home *** CD-ROM | disk | FTP | other *** search
- /*
- CDScan - An XFCN to scan absolute minute, second, block
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/10/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C -q2 CDScan.c
- link -sn Main=CDScan -sn STDIO=CDScan ∂
- -sn INTENV=CDScan -rt XFCN=42 ∂
- -m CDSCAN CDScan.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"StdCLib.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
-
- /* prototype definitions for functions */
- void ExtractBCD(char *, short *);
- OSErr AScan(short, short, short, short, short);
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDScan
- *
- * Purpose: Scan absolute minute, second and block
- *
- * Returns: result of driver call to Scan
- * normally 0, but could have parameter error or
- * other error if non-existent block is specified
- *
- * Side Effects:
- *
- * Description: We need four parameters:
- * 1) the direction - 0 is forward, 1 is reverse
- * 2) the minute
- * 3) the second
- * 4) the block
- * Get the famous global ioRefNum.
- * Extract the minute, second and block and start
- * Scanning at that point.
- *
- ************************************************************************/
- pascal void
- CDScan(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Str31 returnString;
- OSErr result;
- short minute;
- short second;
- short block;
- short ioRefNum;
- Handle refHandle;
- short direction;
-
- /* Must be four parameters */
- if ((paramPtr->paramCount) != 4)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- ioRefNum = atoi(*(refHandle));
- DisposHandle(refHandle);
- ioRefNum &= 0xFFFF; /* remove vRefNum; not needed. */
-
- /* First param is direction. Convert it to a short */
- direction = atoi(*(paramPtr->params[0]));
-
- /* Second param is minute. Convert it to a BCD number */
- ExtractBCD((char *)*(paramPtr->params[1]), &minute);
-
- /* Third param is second. Convert it to a BCD number */
- ExtractBCD((char *)*(paramPtr->params[2]), &second);
-
- /* Fourth param is block. Convert it to a BCD number */
- ExtractBCD((char *)*(paramPtr->params[3]), &block);
-
- result = AScan(ioRefNum, direction, minute, second, block);
-
- /* Convert result to string & return it */
- NumToStr(paramPtr, (long) result, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
-
- /************************************************************************
- *
- * Function: ExtractBCD
- *
- * Purpose: Extract number in BCD from CString
- *
- * Returns: nothing
- *
- * Side Effects: *track gets a new BCD value
- *
- * Description: Extract number in BCD from Cstring "name".
- * "name" is always of the form "XX", where XX
- * ranges from "1" to "99"
- *
- ************************************************************************/
- void
- ExtractBCD(name, number)
- char *name;
- short *number;
- {
- short t;
-
- t = 0;
- while (*name != 0)
- {
- t *= 16;
- t += *name - '0';
- name++;
- }
-
- *number = t;
- }
-
- /************************************************************************
- *
- * Function: AScan
- *
- * Purpose: start Scaning at an absolute minute, second, block
- *
- * Returns: OSErr. Probably either
- * noErr everything's hunky-dory!
- * paramErr you messed up the call somehow.
- *
- * Side Effects: starts Scan. By default, this will Scan until the
- * end of the disc.
- *
- * Description: pass in the absolute minute, second and block in BCD.
- *
- ************************************************************************/
- OSErr
- AScan(refNum, direction, minute, second, block)
- short refNum;
- short direction;
- short minute;
- short second;
- short block;
- {
- CDPlayParam myPB;
-
- myPB.ioCompletion = 0;
- myPB.ioNamePtr = (char *) 0;
- myPB.ioVRefNum = 1;
- myPB.ioCRefNum = refNum;
- myPB.csCode = ASCAN;
-
- myPB.addrFormat = AMSFADDR;
- myPB.unused = 0; /* must be in BCD */
- myPB.minute = (char) minute; /* must be in BCD */
- myPB.second = (char) second; /* must be in BCD */
- myPB.block = (char) block; /* must be in BCD */
- myPB.stopAddress = direction;
- return (PBControl(&myPB, false));
- }
-
-
- /* C routines for HyperCard callbacks */
- #include <XCmdGlue.inc.c>
-